﻿///***************************************************************
/// 시  스  템 : Updms.Com.Dac
/// 단위시스템 : COM
/// 계      층 : Data Access Layer
/// 프로그램명 : Com_Dac_UPDMS_COM_FILE
/// 파  일  명 : Com_Dac_UPDMS_COM_FILE.cs
/// 설      명 : 첨부파일
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2013-06-13 송시명   최초 작성
///***************************************************************
using System.Data;
using System.Data.SqlClient;
using System.EnterpriseServices;
using System.Runtime.InteropServices;

using SMFramework.Data;


namespace Updms.Com.Dac
{
	[ComVisible(true)]
	[Transaction(TransactionOption.Supported)]
	[JustInTimeActivation(true)]
	public class Com_Dac_UPDMS_COM_FILE : Base.AppFramework.DacBase
	{
		public Com_Dac_UPDMS_COM_FILE()
		{
		}

		#region NT [GetFileInfoByActivityId]
		/// <summary>
		/// 액티비티(프로그램별 Seq)별로 첨부파일의 정보를 조회
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public DataSet GetFileInfoByActivityId(DataPack lo_dp)
		{
			string ls_sql = "usp_UPDMS_COM_FILE_Get_File_Info_By_Activity_Id";

			SqlParameter[] paramArray = lo_dp.ToSqlParameters();

			DataSet ds = new DataSet();
			return _agent.Fill(ls_sql, "UPDMS_COM_FILE", ds, paramArray, CommandType.StoredProcedure);
		}

		#endregion

		#region NT [GetFileInfoByHashKey]
		/// <summary>
		/// 해쉬키로 첨부파일의 정보를 조회
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public DataSet GetFileInfoByHashKey(DataPack lo_dp)
		{
			string ls_sql = "usp_UPDMS_COM_FILE_Get_File_Info_By_Hash_Key";

			SqlParameter[] paramArray = lo_dp.ToSqlParameters();

			DataSet ds = new DataSet();
			return _agent.Fill(ls_sql, "UPDMS_COM_FILE", ds, paramArray, CommandType.StoredProcedure);
		}

		#endregion

		#region RT [Insert]
		/// <summary>
		/// 첨부파일을 삭제후 저장
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public int Insert(DataPack lo_dp)
		{
			string ls_sql = "usp_UPDMS_COM_FILE_Insert_Xml";

			SqlParameter[] paramArray = lo_dp.ToSqlParameters();
			return _agent.ExecuteNonQuery(ls_sql, paramArray, CommandType.StoredProcedure);
		}

		#endregion

		#region RT [Delete]
		/// <summary>
		/// 첨부파일을 삭제한다.
		/// </summary>
		/// <param name="ls_xml"></param>
		/// <returns></returns>
		[AutoComplete]
		public int Delete(string ls_xml)
		{
			string ls_sql = "usp_UPDMS_COM_FILE_Delete";

			SqlParameter[] paramArray =
			{
				new SqlParameter("ls_xml", ls_xml)
			};

			return _agent.ExecuteNonQuery(ls_sql, paramArray, CommandType.StoredProcedure);
		}

		#endregion

		#region RT [DeleteByFileId]
		/// <summary>
		/// 특정 파일만 삭제
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public int DeleteByFileId(string ls_xml)
		{
			string ls_sql = "usp_UPDMS_COM_FILE_Delete_By_File_Id";

			SqlParameter[] paramArray =
			{
				new SqlParameter("ls_xml", ls_xml)
			};

			return _agent.ExecuteNonQuery(ls_sql, paramArray, CommandType.StoredProcedure);
		}

		#endregion

	}
}
